#!/usr/bin/python3

import logging
import subprocess
import sys
from pathlib import Path

from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QApplication

from config import log_path, version
from mainwindow import ArmGiaWindow

# Настройка логирования
subprocess.run(f'touch {log_path}', shell=True)
for handler in logging.root.handlers[:]:
    logging.root.removeHandler(handler)
logging.basicConfig(
    filename=log_path,
    format=f'%(asctime)s %(filename)s %(funcName)s() [LINE:%(lineno)d] {" "*15} %(message)s',
    level=logging.INFO,
)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    app.setStyleSheet(Path('style.qss').read_text())
    app.setWindowIcon(QIcon('arm-gia9.svg'))
    window = ArmGiaWindow()
    logging.info(f'Приложение запущено, версия: {version}')
    sys.exit(app.exec_())
